﻿
using System;
using System.Web;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Web.SessionState;
using Dos.Common;

using System.Collections.Generic;
namespace ChatOnline.Login
{
    /// <summary>
    /// LoginHandler 的摘要说明
    /// </summary>
    public class LoginHandler : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            string re = "";
            if (context.Session["ranCode"] == null)
            {
                re = "{\"result\":\"1\",\"msg\":\"验证码获取错误,请重试！\"}";
                context.Response.Write(re);
                return;
            }

            string randomCode = context.Session["ranCode"].ToString().Trim().ToLower();  //获取验证码,并转为小写
            string enterCode = context.Request.Form["validateCode"].ToString().Trim().ToLower();
            if (!randomCode.Equals(enterCode))  //验证码校对
            {
                re = "{\"result\":\"1\",\"msg\":\"验证码不正确,请重试！\"}";
                context.Response.Write(re);
                return;
            }
            re = "{\"result\":\"0\",\"msg\":\"success\"}";
            context.Response.Write(re);
        }
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}